Conditions | 9 |
Paths | 6 |
Total Lines | 33 |
Code Lines | 25 |
Lines | 1 |
Ratio | 3.03 % |
Changes | 0 |
1 | 'use strict'; |
||
11 | View Code Duplication | function nextTick(fn, arg1, arg2, arg3) { |
|
|
|||
12 | if (typeof fn !== 'function') { |
||
13 | throw new TypeError('"callback" argument must be a function'); |
||
14 | } |
||
15 | var len = arguments.length; |
||
16 | var args, i; |
||
17 | switch (len) { |
||
18 | case 0: |
||
19 | case 1: |
||
20 | return process.nextTick(fn); |
||
21 | case 2: |
||
22 | return process.nextTick(function afterTickOne() { |
||
23 | fn.call(null, arg1); |
||
24 | }); |
||
25 | case 3: |
||
26 | return process.nextTick(function afterTickTwo() { |
||
27 | fn.call(null, arg1, arg2); |
||
28 | }); |
||
29 | case 4: |
||
30 | return process.nextTick(function afterTickThree() { |
||
31 | fn.call(null, arg1, arg2, arg3); |
||
32 | }); |
||
33 | default: |
||
34 | args = new Array(len - 1); |
||
35 | i = 0; |
||
36 | while (i < args.length) { |
||
37 | args[i++] = arguments[i]; |
||
38 | } |
||
39 | return process.nextTick(function afterTick() { |
||
40 | fn.apply(null, args); |
||
41 | }); |
||
42 | } |
||
43 | } |
||
44 | |||
45 |